package com.hive.decode;

import java.io.BufferedWriter;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.List;

public class FileUtils {


    public static void writeFileLine(String fileName, String encode, List<String> data) throws IOException {
        OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(fileName,true), encode);
        BufferedWriter bw = new BufferedWriter(writer);
        try {
            for (int i = 0; i < data.size(); i++) {
                bw.write(data.get(i));
                bw.newLine();
            }
        } catch (IOException e) {
            System.out.println("写入文件失败");
        } finally {
            if (bw != null) {
                bw.close();
            }
            if (writer != null) {
                writer.close();
            }

        }

    }

}
